﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace GBH.Models.Dao
{
    public class ExportDetailPiDao
    {
        public IEnumerable<ExportPiDetail> GetExportPi(int exportId)
        {
            using (var db = new GBHEntities())
            {
                var export = from e in db.ExportPiDetails
                             join m in db.stocks on e.productId equals m.product_id
                             where e.ExportId == exportId && e.qty > 0 && m.location_id ==e.branchCode

                             select new ExportPiDetail
                             {
                                 productId = e.productId,
                                 productName = e.productName,
                                 branchCode = e.branchCode,
                                 qty = e.qty,
                                 UnitTypeName = m.unit_type_name
                             };
                return export;
            }
        }
    }
}